<script type="text/javascript" src="<?php echo URL;?>/js/jFriendly.js"></script>

<script>
    $(document).ready(function(){
 
        $("#titulo").jFriendly("#urlamigable",true);
 
        
    });
	

	function comprueba_email(email){
		id = '<?php echo $_SESSION['login'];?>';
        $.ajax({
			url: '<?php echo URL;?>/ajax/comprueba_email.php?email='+email+'&id='+id,
            success: function(data) {
				console.log(data);
				if(data==1){
					$('#email').val('');
					$('#email').css('border', 'solid 1px red');
					$('#email_existente').show();
				} else {
					$('#email_existente').hide();
				}
            }
        });        
    }	
</script>


<div class='row-fluid'>    

    <form name='form1' id='form1' action='<?php echo URL;?>/admin/productos_nuevo.php' method='post' accept-charset="utf-8" enctype="multipart/form-data" class="form-horizontal">   

		<h3 style='text-align:left;margin-bottom:20px;'>Nuevo Alojamiento</h3>

		<div class="control-group">
			<label class="control-label" for="inputCategoria">Categoría de Alojamiento:</label>
			<div class="controls">
				<?php echo $select_familia;?>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputTitulo">Nombre del Alojamiento:</label>
			<div class="controls">
				<input type='text'  name='titulo' id="titulo" value="<?php echo $data['titulo'];?>" maxlength='200' required placeholder='Nombre del Alojamiento' class='input-xxlarge'/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputUrl">URL Amigable:</label>
			<div class="controls">
				<input type='text'  name='urlamigable' id="urlamigable" value="<?php echo $data['urlamigable'];?>.html" class='input-xxlarge' style='font-weight:bold;color:#E77817;'>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputTitulo">Email:</label>
			<div class="controls">
				<?php $disabled = iif( $data['parent_id']>0,'disabled',''); ?>
				
				<input type='email'  name='email' id="email" value="<?php echo $data['email'];?>" maxlength='200' <?php echo $disabled;?> required placeholder='Email' class='input-xxlarge'/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputTitulo">Sitio Web del Alojamiento:</label>
			<div class="controls">
				<input type='text'  name='web' id="web" value="<?php echo $data['web'];?>" placeholder='Sitio Web del Alojamiento' class='input-xxlarge'/>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label" for="inputTitulo">Persona de Contacto:</label>
			<div class="controls">
				<input type='text'  name='persona_contacto' id="persona_contacto" value="<?php echo $data['persona_contacto'];?>" placeholder='Persona de Contacto' class='input-xxlarge'/>
			</div>
		</div>


		<hr style='border-top:1px solid #333;margin-top:10px;padding-top:10px;'>
		<h3 style='text-align:left;margin-bottom:20px;'>Ubicación del Alojamiento</h3>

		<div class="control-group">
			<label class="control-label" for="inputTitulo">Dirección:</label>
			<div class="controls">
				<input type='text'  name='direccion' id="direccion" value="<?php echo $data['direccion'];?>" required placeholder='Dirección del Alojamiento' class='input-xxlarge' onblur="arma_direccion()"/>
			</div>
		</div>


		<div class="control-group">
			<label class="control-label" for="inputLocalidad">Provincia / Localidad:</label>
			<div class="controls">
				<select name='provincia' required id='provincia' onblur="arma_direccion()">
					<option value='Santa Fe' <?php if($data['provincia']=='Santa Fe') { echo 'selected';} ?> >Santa Fe</option>
					<option value='Entre Ríos' <?php if($data['provincia']=='Entre Ríos') { echo 'selected';} ?> >Entre Ríos</option>
				</select>
				&nbsp;
				<select name='localidad' required id='localidad' onblur="arma_direccion()">
					<?php foreach($Localidades as $clave=>$valor){
						if ($clave==$data['localidad']) { $sel ='selected=selected';} else {$sel='';}
						 echo "<option value='$clave' $sel>$valor</option>";
					} ?>
				</select>
				<input type='text'  name='codigo_postal' id="codigo_postal" value="<?php echo $data['codigo_postal'];?>" required placeholder='Cod.Postal' class='input-small' onblur="arma_direccion()"/>
				<input type='hidden' name='pais' id="pais" value="<?php echo $Config['default_pais'];?>" />
			</div>
		</div>

		<div class='row-fluid'>
			<div class='span4'>
				<b>Teléfono Principal</b><br>
				<input type='text'  name='telefono1' id="telefono1" value="<?php echo $data['telefono1'];?>" maxlength='60' class='input'/>
			</div>

			<div class='span4'>
				<b>Teléfono Alternativo</b><br>	
				<input type='text'  name='telefono2' id="telefono2" value="<?php echo $data['telefono2'];?>" maxlength='60' class='input'/>
			</div>

			<div class='span3'>
				<b>Teléfono Fax</b><br>
				<input type='text'  name='fax' id="fax" value="<?php echo $data['fax'];?>" maxlength='60' class='input'/>
			</div>
		</div>
		<div class='clear'></div>



	
		<br>
		<div style='margin:20px auto;width:400px;'>
			<input type='hidden' name='id' value='0' />
			<input type='hidden' name='accion' value='guardar' />
			<input type='submit' name='submit' class='btn btn-primary boton-guardar' value='Continuar ->'/>
		</div>
    </form>

</div>
<div class='clear'></div>
